package com.slibra.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.slibra.common.annotation.Log;
import com.slibra.common.core.controller.BaseController;
import com.slibra.common.core.domain.AjaxResult;
import com.slibra.common.enums.BusinessType;
import com.slibra.business.domain.TXinyiNormConfig;
import com.slibra.business.service.ITXinyiNormConfigService;
import com.slibra.common.utils.poi.ExcelUtil;
import com.slibra.common.core.page.TableDataInfo;

/**
 * 信义一些指标的配置Controller
 * 
 * @author slibra
 * @date 2024-04-27
 */
@RestController
@RequestMapping("/business/config")
public class TXinyiNormConfigController extends BaseController
{
    @Autowired
    private ITXinyiNormConfigService tXinyiNormConfigService;

    /**
     * 查询信义一些指标的配置列表
     */
    @PreAuthorize("@ss.hasPermi('business:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(TXinyiNormConfig tXinyiNormConfig)
    {
        startPage();
        List<TXinyiNormConfig> list = tXinyiNormConfigService.selectTXinyiNormConfigList(tXinyiNormConfig);
        return getDataTable(list);
    }

    /**
     * 导出信义一些指标的配置列表
     */
    @PreAuthorize("@ss.hasPermi('business:config:export')")
    @Log(title = "信义一些指标的配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TXinyiNormConfig tXinyiNormConfig)
    {
        List<TXinyiNormConfig> list = tXinyiNormConfigService.selectTXinyiNormConfigList(tXinyiNormConfig);
        ExcelUtil<TXinyiNormConfig> util = new ExcelUtil<TXinyiNormConfig>(TXinyiNormConfig.class);
        util.exportExcel(response, list, "信义一些指标的配置数据");
    }

    /**
     * 获取信义一些指标的配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tXinyiNormConfigService.selectTXinyiNormConfigById(id));
    }

    /**
     * 新增信义一些指标的配置
     */
    @PreAuthorize("@ss.hasPermi('business:config:add')")
    @Log(title = "信义一些指标的配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TXinyiNormConfig tXinyiNormConfig)
    {
        tXinyiNormConfig.setCreateBy(getUsername());
        return toAjax(tXinyiNormConfigService.insertTXinyiNormConfig(tXinyiNormConfig));
    }

    /**
     * 修改信义一些指标的配置
     */
    @PreAuthorize("@ss.hasPermi('business:config:edit')")
    @Log(title = "信义一些指标的配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TXinyiNormConfig tXinyiNormConfig)
    {
        tXinyiNormConfig.setUpdateBy(getUsername());
        return toAjax(tXinyiNormConfigService.updateTXinyiNormConfig(tXinyiNormConfig));
    }

    /**
     * 删除信义一些指标的配置
     */
    @PreAuthorize("@ss.hasPermi('business:config:remove')")
    @Log(title = "信义一些指标的配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tXinyiNormConfigService.deleteTXinyiNormConfigByIds(ids));
    }
}
